<!DOCTYPE html>
<html xmlns:text-align="http://www.w3.org/1999/xhtml">
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.0.js"></script>

		<style type="text/css">
			/*form {*/
				/*!*text-align:center; !*设置水平居中*!*!*/
			/*}*/
			ul{
				list-style: none;
				width:40%;
				margin:0 auto;
				border: 1px solid #BFBFBF;
			}
			div{
				text-align:center
			}

		</style>
	</head>

	<body  >
		<form>
			<ul  id="content" >
				<li><a href="javascript:;" onclick="downloadFile(this);"></a></li>
			</ul>
			<div >
				<input type="text" placeholder="输入第几页"  id="pageNO"/>
				<input type="text" placeholder="输入要查询的种子"  id="name"/>
				<input type="button" value="查询" id="signup"/>
			</div>
		</form>

		<script>
            //    var host = "http://prdear.imwork.net:17406";
            //一定记住要写http
            var host = "http://localhost:8080"
			$(function(){
				$("#signup").click(function(){
					var data=JSON.stringify(
						{
							"pageNO": parseInt($("#pageNO").val()),
                            "name":$("#name").val()
						});
					$.ajax({
						type:"POST",
						contentType: "application/json; charset=utf-8",
						url:host+"/file/showfile",
						async:true,
						dataType:"json",
						data:data,
						success:function(data){
							if(data.msg=="success"){
								var aLi=data.data;
								var length=aLi.length;
								var ohtml="";
								for(var i=0;i<length;i++){
									ohtml+='<li><a href="javascript:;" onclick="downloadFile(this);">'+aLi[i]+'</a></li>';
								}
								$("#content").html(ohtml);
							}else{
								console.log("error");
							}
						},
						error:function(xhr, textStatus, errorThrown) {
						 	console.log(xhr.status);
						}
					});
				});
			})
			function downloadFile(obj){
				var data=$(obj).text();
                var down = host+"/file/down?fileName="+data;
              window.location.href=down;
			/*	console.log(data);
				$.ajax({
						type:"GET",
						contentType: "application/json; charset=utf-8",
						url:"/file/down?fileName="+data,
						async:true,
						dataType:"json",
						data:data,
						success:function(data){
							//具体操作
						},
						error:function(xhr, textStatus, errorThrown) {
						 	console.log(xhr.status);
						}
					});*/
			}
		</script>
	</body>
</html>
